package com.example.springboot.controller;

import com.example.springboot.pojo.Address;
import com.example.springboot.pojo.Result;
import com.example.springboot.pojo.Student;
import com.sun.net.httpserver.Authenticator;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController //@Controller+@responseBody
public class ReturnController {
    @RequestMapping("/stringReturn")
    public Result helloWorld() {
        String str = "helloworld";
        return Result.success(str);
    }

    @RequestMapping("/entryReturn")
    public Student entryReturn() {
        return new Student("张三", 13, "男", new Address("山东", "潍坊"));
    }

    @RequestMapping("/listReturn")
    public Result listReturn() {
        Student stu = new Student("张三", 13, "男", new Address("山东", "潍坊"));
        Student stu1 = new Student("张三", 13, "男", new Address("山东", "潍坊"));
        Student stu2 = new Student("张三", 13, "男", new Address("山东", "潍坊"));
        Student stu3 = new Student("张三", 13, "男", new Address("山东", "潍坊"));
        ArrayList<Student> al = new ArrayList<>();
        al.add(stu);
        al.add(stu1);
        al.add(stu2);
        al.add(stu3);
//        return al;
        return Result.success(al);


    }
    @RequestMapping("/errorReturn")
    public Result errorReturn() {

        return  Result.error("用户名密码错误");
    }


}
